package com.study.design.pattern.pattern.behavioral.command;

/**
 * @Author: gongsl
 * @Date: 2025-03-24 23:23
 * @description: 客户端
 */
public class CommandTest {
    public static void main(String[] args) {
        TV tv = new TV();

        Command turnOn = new TurnOnCommand(tv);
        Command turnOff = new TurnOffCommand(tv);

        RemoteControl remote = new RemoteControl();

        remote.setCommand(turnOn);
        // 电视已打开
        remote.pressButton();
        // 电视已关闭
        remote.pressUndo();
        System.out.println("---------");
        remote.setCommand(turnOff);
        // 电视已关闭
        remote.pressButton();
        // 电视已打开
        remote.pressUndo();
    }
}
